package com.wenhui.schoolyardinfo.base;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.hjq.toast.ToastUtils;
import com.qmuiteam.qmui.util.QMUIStatusBarHelper;
import com.qmuiteam.qmui.widget.QMUITopBar;
import com.wenhui.schoolyardinfo.MineApplication;
import com.wenhui.schoolyardinfo.R;

/**
 * author    : Urasaki
 * e-mail    : 1164688204@qq.com
 * date      : 2019/6/12B 16:12
 * introduce :
 */

public abstract class BaseFragment extends Fragment {

    protected MineApplication mineApplication;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mineApplication = (MineApplication) getActivity().getApplication();
    }

    protected abstract void initData();

    protected abstract void initViews();

    protected void setTopBar(QMUITopBar topbar) {
        topbar.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.colorWhiteA));
        topbar.addLeftBackImageButton().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getActivity().finish();
            }
        });
        // 沉浸式状态栏
        QMUIStatusBarHelper.translucent(getActivity());
        //设置状态栏黑色字体和图标，
        //支持4.4以上的MIUI和flyme  以及5.0以上的其他android
        QMUIStatusBarHelper.setStatusBarLightMode(getActivity());

    }

    protected void showToast(String message) {
        ToastUtils.show(message);
    }

    protected void startActivity(Class<?> cls) {
        Intent intent = new Intent(getActivity(), cls);
        startActivity(intent);
    }

}
